const mongoose = require("mongoose");

// 经验值记录表
const ExpRecordSchema = new mongoose.Schema({
    // 用户的openid
    openid: {
        type: String,
        required: true,
        index: true
    },
    // 经验值类型：login, post, comment, like, share等
    type: {
        type: String,
        required: true
    },
    // 获取的经验值
    value: {
        type: Number,
        required: true
    },
    // 描述
    description: {
        type: String
    },
    // 创建时间
    createdAt: {
        type: Date,
        default: Date.now
    }
});

// 创建索引以提高查询效率
ExpRecordSchema.index({ openid: 1, type: 1, createdAt: -1 });

module.exports = mongoose.model('ExpRecord', ExpRecordSchema); 